package com.corpgovernment.organization.processor;

import com.corpgovernment.api.organization.dto.request.QueryExpressAddressRequestDto;
import com.corpgovernment.api.organization.model.expressaddress.ExpressAddressVo;
import com.corpgovernment.common.base.BaseProcessor;
import com.corpgovernment.common.base.JSONResult;
import com.corpgovernment.common.utils.BaseUtils;
import com.corpgovernment.organization.service.impl.QueryExpressAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.lang.invoke.MethodHandles;

/**
 * @author sbwu
 * @date:2019-09-24
 */
@Component
public class QueryExpressAddressProcessor extends BaseProcessor<QueryExpressAddressRequestDto, ExpressAddressVo> {
    private static final String Title = MethodHandles.lookup().lookupClass().getSimpleName();
    @Autowired
    private QueryExpressAddressService queryExpressAddressService;

    @Override
    protected void init(QueryExpressAddressRequestDto request) {
        BaseUtils.putLogTitle(Title);
        BaseUtils.trim(request);
        BaseUtils.putLogTag("SID", request.getSessionId());
    }

    @Override
    protected void validate(QueryExpressAddressRequestDto request) {
        BaseUtils.verifyNotNull(request.getUid(), "用户id不允许为空");
        BaseUtils.verifyNotNull(request.getExpressAddressProductTypeEnum(), "产线类型不允许为空");
        BaseUtils.verifyNotNull(request.getCorpPayType(), "出行类型不允许为空");
        BaseUtils.verifyNotNull(request.getPayType(), "支付方式不允许为空");
    }

    @Override
    protected JSONResult<ExpressAddressVo> processing(QueryExpressAddressRequestDto request) {
        return queryExpressAddressService.queryExpressAddress(request);
    }


}
